#ifndef DamageWidget_h
#define DamageWidget_h

#include "Widget.h"

class DamageWidget : public Widget
{
public:
	DamageWidget(int p_damage_done, Vector2 p_position, bool p_crit)
	: Widget(DAMAGEWIDGET, p_position-Vector2(0,10*1e9) , color(255,255,255,255) )
	{
		m_damage_done = p_damage_done;
		m_crit = p_crit;

		m_start_position = m_position;
		m_end_position = m_position - Vector2(0,75*1e9);
	}
	int getDamageDone() const
	{
		return m_damage_done;
	}
	bool getCritical() const
	{
		return m_crit;
	}
	virtual bool getFinished() const
	{
		return (bool)( getAge() > GC_DAMAGEWIDGET_DURATION);
	}
	virtual void tick()
	{
		Widget::tick();

		double life_fraction = getAge()/GC_DAMAGEWIDGET_DURATION;

		m_position = m_start_position + (m_end_position-m_start_position)*life_fraction;
	}
protected:
	int m_damage_done;
	bool m_crit;
	Vector2 m_start_position;
	Vector2 m_end_position;
};

#endif //DamageWidget_h
